Track free pages live rather than count pages in all nodes/zones
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 8 Dec 2009 07:55:21 +0000 (07:55 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 8 Dec 2009 07:55:21 +0000 (07:55 +0000)
commit272c176b86a1e442f9ec0bddf44034fbe0aa26c1
treef78ef071bf278cd240965169e8c468fca8796ac0
parentb9c20c78789f94b3b550d0a9d694662cba5fa794
Track free pages live rather than count pages in all nodes/zones

Trying to fix a livelock condition in tmem that occurs
only when the system is totally out of memory requires
the ability to easily determine if all zones in all
nodes are empty, and this must be checked at a fairly
high frequency.  So to avoid walking all the zones in
all the nodes each time, I'd like a fast way to determine
if "free_pages" is zero.  This patch tracks the sum
of the free pages in all nodes/zones.  Since I think
the value is modified only when heap_lock is held,
it need not be atomic.

I don't know this for sure, but suspect this will be
useful in other future memory utilization code, e.g.
page sharing.

This has had limited testing, though I did drive free
memory down to zero and up and down a few times with
debug on and no asserts were triggered.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
xen/common/page_alloc.c
xen/include/xen/mm.h